<!--
 * @Author: ChaiHongJun
 * @Date: 2021-03-23 17:37:41
 * @LastEditors: ChaiHongJun
 * @LastEditTime: 2021-04-28 15:23:13
 * @version: 
 * @Description: 推荐歌手组件
-->
<template>
  <div class="recommend-singer">
    <h2 class="title">推荐歌手</h2>

    <ul class="singer-list" v-loading="loadingRecommend">
      <li v-for="artist of getArtists" :key="artist.id">
        <div class="cover">
          <div class="image">
            <el-image :src="artist.picUrl + '?param=200y200'"></el-image>
          </div>
        </div>
        <div class="info">
          <p class="name">{{ artist.name }}</p>
          <p class="count">单曲:{{ artist.musicSize }}</p>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
export default {
  data() {
    return {
      loadingRecommend: false,
      offset: 0, //分页
      limit: 10, // 每页数量
      singers: [],
    };
  },
  computed: {
    ...mapGetters(["getArtists"]),
  },
  mounted() {
    this.loadingRecommend = true;
    this.$store.dispatch("getArtists", {
      offset: this.offset,
      limit: this.limit,
    });
    this.loadingRecommend = false;
  },
  methods: {},
};
</script>

<style lang="stylus" scoped>
.recommend-singer {
  margin-top: 40px;

  .title {
    margin: 0 0 15px 0;
  }

  .singer-list {
    display: flex;
    flex-wrap: wrap;
    margin-top: 30px;
    margin: 0px -15px 0;
  }
}

li {
  padding: 0 15px 30px;
  flex: 0 0 10%;
  max-width: 10%;

  .cover {
    position: relative;
    z-index: 2;
    padding-top: 100%;
    border-radius: 50%;
    background-color: #d9d9d9;

    .image {
      position: absolute;
      top: 0;
      left: 0;
      overflow: hidden;
      width: 100%;
      height: 100%;
      border-radius: 50%;

      img {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 100%;
      }

      &:after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 50%;
        -webkit-box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.05) inset, -1px -1px 0 rgba(0, 0, 0, 0.05) inset;
        box-shadow: inset 1px 1px 0 rgba(0, 0, 0, 0.05), inset -1px -1px 0 rgba(0, 0, 0, 0.05);
      }
    }
  }

  .info {
    margin-top: 15px;
    text-align: center;

    .name {
      font-weight: 700;
      font-size: 14px;
      line-height: 18px;
      word-break: break-word;
    }

    .count {
      font-size: 12px;
      margin-top: 10px;
      color: $color-theme;
    }
  }
}
</style>